#region License
/* Copyright (C) 2009 Tim Coulter
 * 
 * This file is part of ExtremeML.
 * 
 * ExtremeML is free software: you can redistribute
 * it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 * the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
*/
#endregion

using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using ExtremeML.Core;
using ExtremeML.Packaging;
using ExtremeML.Spreadsheet;

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="WorkbookPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class WorkbookPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.WorkbookPart>
	{
		private string _relationshipType;

		/// <summary>
		/// Initializes a new instance of the <see cref="WorkbookPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.WorkbookPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal WorkbookPartWrapper(
			DocumentFormat.OpenXml.Packaging.WorkbookPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorkbookPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.SharedStringTablePartWrapper"/> instance.
		/// </summary>
		public ExtremeML.Packaging.SharedStringTablePartWrapper SharedStringTablePart { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.WorkbookStylesPartWrapper"/> instance.
		/// </summary>
		public ExtremeML.Packaging.WorkbookStylesPartWrapper WorkbookStylesPart { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.ThemePartWrapper"/> instance.
		/// </summary>
		public ExtremeML.Packaging.ThemePartWrapper ThemePart { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.WorksheetPartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.WorksheetPartWrapperCollection WorksheetParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.WorkbookWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.WorkbookWrapper Workbook { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			SharedStringTablePart = new ExtremeML.Packaging.SharedStringTablePartWrapper(null, this, Package);
			WorkbookStylesPart = new ExtremeML.Packaging.WorkbookStylesPartWrapper(null, this, Package);
			ThemePart = new ExtremeML.Packaging.ThemePartWrapper(null, this, Package);
			WorksheetParts = new ExtremeML.Packaging.WorksheetPartWrapperCollection(null, this, Package);
			Workbook = new ExtremeML.Spreadsheet.WorkbookWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			WorksheetParts = new ExtremeML.Packaging.WorksheetPartWrapperCollection(Wrapped, this, Package);
			SharedStringTablePart = new ExtremeML.Packaging.SharedStringTablePartWrapper(Wrapped.SharedStringTablePart, this, Package);
			WorkbookStylesPart = new ExtremeML.Packaging.WorkbookStylesPartWrapper(Wrapped.WorkbookStylesPart, this, Package);
			ThemePart = new ExtremeML.Packaging.ThemePartWrapper(Wrapped.ThemePart, this, Package);
			Workbook = new ExtremeML.Spreadsheet.WorkbookWrapper(Wrapped.Workbook, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				SharedStringTablePart.Recompose(result);
				WorkbookStylesPart.Recompose(result);
				ThemePart.Recompose(result);
				WorksheetParts.Recompose(result);
				Workbook.Recompose(result.Workbook);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return SharedStringTablePart;
			yield return WorkbookStylesPart;
			yield return ThemePart;
			yield return WorksheetParts;
			yield return Workbook;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region VariableContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.WorkbookPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.WorkbookPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.WorkbookPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			return CreateCustomDefaultPart(container, args);
		}

		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="SharedStringTablePart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class SharedStringTablePartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.SharedStringTablePart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="SharedStringTablePartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.SharedStringTablePart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal SharedStringTablePartWrapper(
			DocumentFormat.OpenXml.Packaging.SharedStringTablePart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.SharedStringTablePart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.SharedStringTablePart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.SharedStringTableWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.SharedStringTableWrapper SharedStringTable { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			SharedStringTable = new ExtremeML.Spreadsheet.SharedStringTableWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			SharedStringTable = new ExtremeML.Spreadsheet.SharedStringTableWrapper(Wrapped.SharedStringTable, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				SharedStringTable.Recompose(result.SharedStringTable);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return SharedStringTable;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.SharedStringTablePart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.SharedStringTablePart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.SharedStringTablePart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.SharedStringTablePart>();
				result.SharedStringTable = ExtremeML.Spreadsheet.SharedStringTableWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="WorkbookStylesPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class WorkbookStylesPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.WorkbookStylesPart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="WorkbookStylesPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.WorkbookStylesPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal WorkbookStylesPartWrapper(
			DocumentFormat.OpenXml.Packaging.WorkbookStylesPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorkbookStylesPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorkbookStylesPart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.StylesheetWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.StylesheetWrapper Stylesheet { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			Stylesheet = new ExtremeML.Spreadsheet.StylesheetWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			Stylesheet = new ExtremeML.Spreadsheet.StylesheetWrapper(Wrapped.Stylesheet, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				Stylesheet.Recompose(result.Stylesheet);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return Stylesheet;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.WorkbookStylesPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.WorkbookStylesPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.WorkbookStylesPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.WorkbookStylesPart>();
				result.Stylesheet = ExtremeML.Spreadsheet.StylesheetWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="ThemePart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class ThemePartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.ThemePart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="ThemePartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.ThemePart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal ThemePartWrapper(
			DocumentFormat.OpenXml.Packaging.ThemePart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.ThemePart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.ThemePart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.ImagePartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.ImagePartWrapperCollection ImageParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Drawing.ThemeWrapper"/> instance.
		/// </summary>
		public ExtremeML.Drawing.ThemeWrapper Theme { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(null, this, Package);
			Theme = new ExtremeML.Drawing.ThemeWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(Wrapped, this, Package);
			Theme = new ExtremeML.Drawing.ThemeWrapper(Wrapped.Theme, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				ImageParts.Recompose(result);
				Theme.Recompose(result.Theme);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return ImageParts;
			yield return Theme;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.ThemePart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.ThemePart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.ThemePart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.ThemePart>();
				result.Theme = ExtremeML.Drawing.ThemeWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="ImagePart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class ImagePartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.ImagePart>
	{
		private string _relationshipType;

		/// <summary>
		/// Initializes a new instance of the <see cref="ImagePartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.ImagePart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal ImagePartWrapper(
			DocumentFormat.OpenXml.Packaging.ImagePart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.ImagePart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);


				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		#region VariableContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.ImagePart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.ImagePart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.ImagePart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			return CreateCustomDefaultPart(container, args);
		}

		#endregion
		#region CollectionPartPattern Implementation

		/// <summary>
		/// Gets the Id used by the parent part to reference this part.
		/// </summary>
		internal string Id
		{
			get { return ((OpenXmlPartContainer)Parent.GetWrappedContentObject()).GetIdOfPart(Wrapped); }
		}
		
		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="WorksheetPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class WorksheetPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.WorksheetPart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="WorksheetPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.WorksheetPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal WorksheetPartWrapper(
			DocumentFormat.OpenXml.Packaging.WorksheetPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorksheetPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorksheetPart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.VmlDrawingPartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.VmlDrawingPartWrapperCollection VmlDrawingParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.WorksheetCommentsPartWrapper"/> instance.
		/// </summary>
		public ExtremeML.Packaging.WorksheetCommentsPartWrapper WorksheetCommentsPart { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.TableDefinitionPartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.TableDefinitionPartWrapperCollection TableDefinitionParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.ImagePartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.ImagePartWrapperCollection ImageParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.QueryTablePartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.QueryTablePartWrapperCollection QueryTableParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.WorksheetWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.WorksheetWrapper Worksheet { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			VmlDrawingParts = new ExtremeML.Packaging.VmlDrawingPartWrapperCollection(null, this, Package);
			WorksheetCommentsPart = new ExtremeML.Packaging.WorksheetCommentsPartWrapper(null, this, Package);
			TableDefinitionParts = new ExtremeML.Packaging.TableDefinitionPartWrapperCollection(null, this, Package);
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(null, this, Package);
			QueryTableParts = new ExtremeML.Packaging.QueryTablePartWrapperCollection(null, this, Package);
			Worksheet = new ExtremeML.Spreadsheet.WorksheetWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			VmlDrawingParts = new ExtremeML.Packaging.VmlDrawingPartWrapperCollection(Wrapped, this, Package);
			TableDefinitionParts = new ExtremeML.Packaging.TableDefinitionPartWrapperCollection(Wrapped, this, Package);
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(Wrapped, this, Package);
			QueryTableParts = new ExtremeML.Packaging.QueryTablePartWrapperCollection(Wrapped, this, Package);
			WorksheetCommentsPart = new ExtremeML.Packaging.WorksheetCommentsPartWrapper(Wrapped.WorksheetCommentsPart, this, Package);
			Worksheet = new ExtremeML.Spreadsheet.WorksheetWrapper(Wrapped.Worksheet, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				VmlDrawingParts.Recompose(result);
				WorksheetCommentsPart.Recompose(result);
				TableDefinitionParts.Recompose(result);
				ImageParts.Recompose(result);
				QueryTableParts.Recompose(result);
				Worksheet.Recompose(result.Worksheet);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return VmlDrawingParts;
			yield return WorksheetCommentsPart;
			yield return TableDefinitionParts;
			yield return ImageParts;
			yield return QueryTableParts;
			yield return Worksheet;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.WorksheetPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.WorksheetPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.WorksheetPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.WorksheetPart>();
				result.Worksheet = ExtremeML.Spreadsheet.WorksheetWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
		#region CollectionPartPattern Implementation

		/// <summary>
		/// Gets the Id used by the parent part to reference this part.
		/// </summary>
		internal string Id
		{
			get { return ((OpenXmlPartContainer)Parent.GetWrappedContentObject()).GetIdOfPart(Wrapped); }
		}
		
		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="VmlDrawingPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class VmlDrawingPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.VmlDrawingPart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="VmlDrawingPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.VmlDrawingPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal VmlDrawingPartWrapper(
			DocumentFormat.OpenXml.Packaging.VmlDrawingPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.VmlDrawingPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.VmlDrawingPart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.ImagePartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.ImagePartWrapperCollection ImageParts { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			ImageParts = new ExtremeML.Packaging.ImagePartWrapperCollection(Wrapped, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				ImageParts.Recompose(result);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return ImageParts;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.VmlDrawingPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.VmlDrawingPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.VmlDrawingPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.VmlDrawingPart>();
			}

			return result;			
		}

		#endregion
		#region CollectionPartPattern Implementation

		/// <summary>
		/// Gets the Id used by the parent part to reference this part.
		/// </summary>
		internal string Id
		{
			get { return ((OpenXmlPartContainer)Parent.GetWrappedContentObject()).GetIdOfPart(Wrapped); }
		}
		
		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="WorksheetCommentsPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class WorksheetCommentsPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="WorksheetCommentsPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal WorksheetCommentsPartWrapper(
			DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.CommentsWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.CommentsWrapper Comments { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			Comments = new ExtremeML.Spreadsheet.CommentsWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			Comments = new ExtremeML.Spreadsheet.CommentsWrapper(Wrapped.Comments, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				Comments.Recompose(result.Comments);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return Comments;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.WorksheetCommentsPart>();
				result.Comments = ExtremeML.Spreadsheet.CommentsWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="TableDefinitionPart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class TableDefinitionPartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.TableDefinitionPart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="TableDefinitionPartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.TableDefinitionPart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal TableDefinitionPartWrapper(
			DocumentFormat.OpenXml.Packaging.TableDefinitionPart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.TableDefinitionPart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.TableDefinitionPart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Packaging.QueryTablePartWrapperCollection"/> instance.
		/// </summary>
		public ExtremeML.Packaging.QueryTablePartWrapperCollection QueryTableParts { get; private set; }
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.TableWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.TableWrapper Table { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			QueryTableParts = new ExtremeML.Packaging.QueryTablePartWrapperCollection(null, this, Package);
			Table = new ExtremeML.Spreadsheet.TableWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			QueryTableParts = new ExtremeML.Packaging.QueryTablePartWrapperCollection(Wrapped, this, Package);
			Table = new ExtremeML.Spreadsheet.TableWrapper(Wrapped.Table, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				QueryTableParts.Recompose(result);
				Table.Recompose(result.Table);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return QueryTableParts;
			yield return Table;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.TableDefinitionPart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.TableDefinitionPart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.TableDefinitionPart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.TableDefinitionPart>();
				result.Table = ExtremeML.Spreadsheet.TableWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
		#region CollectionPartPattern Implementation

		/// <summary>
		/// Gets the Id used by the parent part to reference this part.
		/// </summary>
		internal string Id
		{
			get { return ((OpenXmlPartContainer)Parent.GetWrappedContentObject()).GetIdOfPart(Wrapped); }
		}
		
		#endregion
	}
}	

namespace ExtremeML.Packaging
{
	/// <summary>
	/// Wraps a <see cref="QueryTablePart"/> and exposes its content as an object graph.
	/// </summary>
	[GeneratedCode("T4", "1.0")]
	public sealed partial class QueryTablePartWrapper : PartWrapper<DocumentFormat.OpenXml.Packaging.QueryTablePart>
	{
		private string _relationshipType;
		private string _contentType;

		/// <summary>
		/// Initializes a new instance of the <see cref="QueryTablePartWrapper"/> class.
		/// </summary>
		/// <param name="wrapped">A <see cref="DocumentFormat.OpenXml.Packaging.QueryTablePart"/> from which to populate this instance.</param>
		/// <param name="parent">An <see cref="IContentWrapper"/> that represents the parent wrapper instance.</param>
		/// <param name="package">An <see cref="IContentWrapper"/> that represents the package wrapper instance.</param>
		internal QueryTablePartWrapper(
			DocumentFormat.OpenXml.Packaging.QueryTablePart wrapped,
			IContentWrapper parent,
			IContentWrapper package)
			: base(wrapped, parent, package)
		{
		}
		
		/// <summary>
		/// Gets the value of the <see cref="RelationshipType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.QueryTablePart"/> instance.
		/// </summary>
		public string RelationshipType
		{
			get { return _relationshipType; }
		}
		
		/// <summary>
		/// Gets the value of the <see cref="ContentType"/> property of the wrapped <see cref="DocumentFormat.OpenXml.Packaging.QueryTablePart"/> instance.
		/// </summary>
		public string ContentType
		{
			get { return _contentType; }
		}
		
		/// <summary>
		/// Gets the contained <see cref="ExtremeML.Spreadsheet.QueryTableWrapper"/> instance.
		/// </summary>
		public ExtremeML.Spreadsheet.QueryTableWrapper QueryTable { get; private set; }
		

		/// <summary>
		/// Clears the content of this instance and populates it using default values.
		/// </summary>
		protected override void OnInitializing()
		{
			base.OnInitializing();
	
			_relationshipType = default(string);
			_contentType = default(string);
			QueryTable = new ExtremeML.Spreadsheet.QueryTableWrapper(null, this, Package);
		}

		/// <summary>
		/// Decomposes the wrapped content object into the properties of this instance.
		/// </summary>
		protected override void OnDecomposing()
		{
			base.OnDecomposing();
	
			_relationshipType = Wrapped.RelationshipType;
			_contentType = Wrapped.ContentType;
			QueryTable = new ExtremeML.Spreadsheet.QueryTableWrapper(Wrapped.QueryTable, this, Package);
		}
		
		/// <summary>
		/// Re-creates the wrapped content object from the properties of this instance.
		/// </summary>
		/// <param name="container">An <see cref="OpenXmlPartContainer"/> that represents the parent content object.</param>
		internal void Recompose(
			OpenXmlPartContainer container)
		{
			var result = Wrapped;

			if (IsPopulated())
			{
				result = result ?? CreateDefaultPart(container);

				OnCustomRecomposing(result);
				if (Recomposing != null) Recomposing(result);

				QueryTable.Recompose(result.QueryTable);

				OnCustomRecomposed(result);
				if (Recomposed != null) Recomposed(result);
			}
		}

		/// <summary>
		/// Occurs when a this instance is requested to persist its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposing;

		/// <summary>
		/// Occurs after a this instance has persisted its content.
		/// </summary>
		private event WrappedContentEventHandler Recomposed;

		/// <summary>
		/// Returns the set of <see cref="IContentWrapper"/> that are exposed as properties.
		/// </summary>
		protected override IEnumerable<IWrapper> GetWrapperMembers()
		{
			yield return QueryTable;

			foreach (var member in GetCustomWrapperMembers())
			{
				yield return member;
			}
		}

		#region FixedContentTypePartPattern Implementation

		/// <summary>
		/// Returns a <see cref="DocumentFormat.OpenXml.Packaging.QueryTablePart"/> populated with the default content.
		/// </summary>
		/// <param name="container">The parent <see cref="OpenXmlPartContainer"/> instance.</param>
	    /// <param name="args">A parameter array of <see cref="object"/> containing member initialization arguments.</param>
		/// <returns>A <see cref="DocumentFormat.OpenXml.Packaging.QueryTablePart"/> populated with default content.</returns>
		internal static DocumentFormat.OpenXml.Packaging.QueryTablePart CreateDefaultPart(
			OpenXmlPartContainer container,
			params object[] args)
		{
			var result = CreateCustomDefaultPart(container, args);
			
			if (result == null)
			{
				result = container.AddNewPart<DocumentFormat.OpenXml.Packaging.QueryTablePart>();
				result.QueryTable = ExtremeML.Spreadsheet.QueryTableWrapper.CreateDefaultElement();
			}

			return result;			
		}

		#endregion
		#region CollectionPartPattern Implementation

		/// <summary>
		/// Gets the Id used by the parent part to reference this part.
		/// </summary>
		internal string Id
		{
			get { return ((OpenXmlPartContainer)Parent.GetWrappedContentObject()).GetIdOfPart(Wrapped); }
		}
		
		#endregion
	}
}	

